package bog

class AnswerController {

    static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

    def upVote() {
        Answer a = Answer.get(params.answerId)

        a.upVote(Long.parseLong(params.userId))
        a.save(flush: true)

        redirect(controller: "thread", action: "show", id: a.thread.id)
    }

    def downVote() {
        Answer a = Answer.get(params.answerId)
        a.downVote(Long.parseLong(params.userId))
        a.save(flush: true)

        redirect(controller: "thread", action: "show", id: a.thread.id)
    }
}
